package com.zjj.concurrent.completableFuture;

import java.util.Random;
import java.util.concurrent.CompletableFuture;

/**
 * @author zhanglei.zjj
 * @description thenRun对任务结果消费，它不会操作前面CompletableFuture的结果
 * @date 2023/6/4 15:11
 */
public class ThenRunTest {
    public static void main(String[] args) {
        CompletableFuture<Void> future = CompletableFuture.supplyAsync(() -> {
            int number = new Random().nextInt(10);
            System.out.println("第一阶段：" + number);
            return number;
        }).thenRun(() ->
                System.out.println("thenRun 执行"));
        System.out.println(future.join());
    }
}
